<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <link rel="stylesheet" href="./libs/layui/css/layui.css">
    <link rel="stylesheet" href="css/forlogin.css"> 
    <script src="./libs/layui/layui.js"></script>

</head>

<body>
<div class="login-container">
    <div class="title">
        <span><img src="images\logo.png" style="height: 50px;">国家能源集团</span>
        <div class="logtit">三维矿山地理信息系统</div>
    </div>
    <div class="right-container">
        <div style="margin-top: 10px; text-align: center; ">

            <div style="text-align: center; margin-top: 30px; font-size: 24px; font-weight: bold; color: #000000">用户登录
            </div>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div style="margin-top: 30px;align-items: center;justify-content: center;display: flex;display: -webkit-flex;">
                        <label class="layui-icon layui-icon-username" name="username"style="float:left">用户名：</label>
                        <input type="text" name="username" lay-verify="required|account" placeholder="请输入用户名"
                               autocomplete="off" class="layui-input" value=""
                               style="font-size:16px; width: 60%; border: 3px solid #dedcdc; padding: 10px">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div style="margin-top:30px;align-items: center;justify-content: center;display: flex;display: -webkit-flex;">
                        <label class="layui-icon layui-icon-password" name="password"style="float:left">密&emsp;码：</label>
                        <input type="password" name="password" lay-verify="required|password" placeholder="请输入密码"
                               autocomplete="off" class="layui-input" value=""
                               style="font-size:16px; width: 60%; border: 3px solid #dedcdc; padding: 10px">
                    </div>
                </div>
<!--                <div class="layui-form-item" style="margin-left: 10px">-->
<!--                    <div class="layui-input-inline" style="font-size:16px;width:340px;margin-top:30px;align-items: center;justify-content: center;display: flex;display: -webkit-flex;">-->
<!--                        请选择平台：-->
<!--                        <select lay-filter="type" id="s_1"-->
<!--                                style="font-size:14px; width: 67%; border: 1px solid #dedcdc; padding: 10px;">-->
<!--                            <option value="1" >露天矿智能地理信息平台</option>-->
<!--                            <option value="2">智慧矿山数据管理系统平台</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item" style="margin-top: 50px">
                    <button class="layui-btn layui-btn layui-btn-normal layui-btn-fluid" lay-submit=""
                            lay-filter="login" id="check" value="登录">登 入
                    </button>
                </div>
            </form>

        </div>
    </div>
</div>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        // 进行登录操作
        form.on('submit(login)', function (data) {
            data = data.field;

            if (data.username == '') {
                layer.msg('用户名不能为空');
                return false;
            }
            if (data.password == '') {
                layer.msg('密码不能为空');
                return false;
            }
            $.ajax({
                type: 'POST',
                // url: 'http://192.168.0.108:8282/kuangqu/sys/user/login',  //后台地址注意要改
                // url: 'http://3510b38g11.zicp.fun:13894/kuangqu/sys/user/login',  //后台地址注意要改
                url:'http://127.0.0.1:8282/kuangqu/sys/user/login',
                dataType: "JSON",
                data: JSON.stringify(data),
                contentType: "application/json",
                success: function (res) {
                    console.log(res)
                    if (res.code == 0) {
                        layui.data('LocalData', {
                            key: "access_token",
                            value: res.data.accessToken
                        })
                        layer.msg('登录成功', {time: 1000}, function () {
                            // if (sel_1 == 1) {
                            //     window.location.href = "index.html";
                            // } else{
                            //     window.location.href = "http://3510b38g11.zicp.fun:13894/kuangqu/index/home.html";
                            // }
                            // // window.location = ctx + 'index/home';
                            window.location.href = "select.html";
                        });
                    } else {
                        layer.msg(res.msg);
                        $("#img").click();
                    }
                }
            })

            return false;
        });
    });







</script>

</body>
</html>
